<?php

namespace app\model;

use think\Model;
use think\facade\Db;

class Post extends Model
{
    protected $table = 'site_post';
    public function hasPost($title)
    {
        return count(self::where('title', $title)->select()->toArray()) != 0;
    }
    public function hasSameContentPost($text)
    {
        return count(self::where('text', $text)->select()->toArray()) != 0;
    }
    public function hasPartition($id)
    {
        return count(Db::connect()->table('site_post_partition')->where('id', $id)->select()->toArray()) != 0;
    }
    public function SavePost($data)
    {
        return self::strict(false)->insertGetId($data);
    }
    public function ChangePost($id, $data)
    {
        self::where('id', $id)->save($data);
    }
}
